<?php

namespace App\Repository\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;

/**
 * Class ProductCategories.
 *
 * @package namespace App\Repository\Models;
 */
class ProductCategories extends Model implements Transformable
{
     use TransformableTrait;

     use SoftDeletes;
    
    
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
     protected $fillable = ['id','pid', 'name', 'cat_sn', 'en_name', 'initial', 'sort', 'attrs', 'first_id', 'root_id', 'level_type', 'pic','is_index_recommend','is_shopindex_recommend','cate_type'];


    const NORMAL_CATE = 1; // 撮合商品分类
    const QUALIFIED_CATE = 2; // 找资质服务分类
    
    public function products(){
        return $this->hasMany(Products::class, 'first_cat', 'id')->where(['is_for_sale'=>1,'is_index_recommend'=>1])->limit('3');
    }


}
